import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './styles/reset.css'
import './util/rem'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import { Toast, List, Loading, Field, ActionSheet, Overlay, Icon, Image as VanImage, Uploader, Area, Popup, Picker, Form, Notify, Dialog } from 'vant'
// import Vconsole from 'vconsole'
import MyButton from './components/button/button.vue'
import 'vant/lib/index.css'
import VueClipboard from 'vue-clipboard2'
import FastClick from 'fastclick'
import VueLazyload from 'vue-lazyload'
import { setToken } from './util/auth'
// import style
import 'swiper/css/swiper.css'

// 全局注册
Vue.use(Dialog)
Vue.use(VueLazyload, {
  preLoad: 1.3,
  loading: require('./assets/images/default.png'),
  attempt: 1
})

if (window.location.href.includes('token=') && window.location.href.includes('&user=')) {
  const temp = window.location.href.split('token=')[1]
  const token = temp.split('&user=')[0]
  const user = decodeURIComponent(temp.split('&user=')[1])
  setToken(token)
  localStorage.setItem('USER', user)
}

// 使用
FastClick.attach(document.body)
// const vConsole = new Vconsole()
// Vue.use(vConsole)
Vue.use(VueClipboard)
Vue.use(Notify)
Vue.use(Form)
Vue.use(Picker)
Vue.use(Popup)
Vue.use(Area)
Vue.use(Uploader)
Vue.use(VanImage)
Vue.use(Icon)
Vue.use(Overlay)
Vue.use(ActionSheet)
Vue.use(Field)
Vue.component('my-button', MyButton)
Vue.use(Toast)
Vue.use(List)
Vue.use(Loading)
Vue.use(VueAwesomeSwiper /* { default options with global component } */)
Vue.config.productionTip = false
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
